import { _decorator, Component, EditBox, Label, Node, PageView, ProgressBar, ScrollView, Slider, Sprite, Toggle, UITransform } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('UIContianer')
export class UIContianer  {
private _mapNode:Map<string,Node>=new Map();
private _mapLabel:Map<string,Label>=new Map();
private _mapSprite:Map<string,Sprite>=new Map();
private _mapProgress:Map<string,ProgressBar> = new Map();
private _mapEditBox:Map<string,EditBox> = new Map();
private _mapSlider:Map<string,Slider> = new Map();
private _mapPageView:Map<string,PageView> = new Map();
private _mapScrollView:Map<string,ScrollView> = new Map();
private _mapToggle:Map<string,Toggle> = new Map();
private _mapUITransform:Map<string,UITransform> = new Map();
private _objMap:any={
    Label:this._mapLabel,
    Sprite:this._mapSprite,
    ProgressBar:this._mapProgress,
    EditBox:this._mapEditBox,
    Slider:this._mapSlider,
    PageView:this._mapPageView,
    ScrollView:this._mapScrollView,
    Toggle:this._mapToggle,
    UITransform:this._mapUITransform
}
addNode(nodeName:string,node:Node){
    if(nodeName.length<=0||!node||this._mapNode.has(nodeName)){
        return;
    }
    this._mapNode.set(nodeName,node);
}
addComp(nodeName:string,compName:string,comp:Component){
    if(nodeName.length<=0||compName.length<=0||!comp){
        return;
    }
    let compMap=this._objMap[compName];
    if(!compMap){
        return;
    }
    compMap.set(nodeName,comp);
}
getNode(nodeName:string){
    if(nodeName.length<=0){
        return null;
    }
    return this._mapNode.get(nodeName);
}
getComp<T>(nodeName:string,compName:string):T{
    if(nodeName.length<=0||compName.length<=0){
        return null;
    }
    let mapComp=this._objMap[compName];
    if(!mapComp){
        return null;
    }
    return mapComp.get(nodeName) as T;
}
}


